package com.etc.service.impl;

import com.etc.dao.UserDao;
import com.etc.dao.VideoDao;
import com.etc.entity.User;
import com.etc.entity.Video;
import com.etc.service.UserService;
import com.etc.service.VideoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (User)表服务实现类
 *
 * @author makejava
 * @since 2021-10-18 21:07:18
 */
@Service
public class VideoServiceImpl implements VideoService {
    @Autowired
    VideoDao dao;

    /**
     * 查询所以视频
     * @return
     */
    @Override
    public PageInfo<Video> queryVideo(int pageNum,int pageSize,String typeName) {
        PageHelper.startPage(pageNum,pageSize);
        List<Video> list = dao.sortVideo(typeName);
        PageInfo<Video> pageIndo = new PageInfo<>(list);
        return pageIndo;
    }

    @Override
    public boolean addVideo(Video video) {
        return dao.addVideo(video)>0;
    }
    /**
     * 按id删除视频
     * @return
     */
    @Override
    public boolean delete(String videoId) {
        return dao.deleteVideo(videoId)>0;
    }

    @Override
    public PageInfo<Video> seekVideo(int pageNum, int pageSize, String videoName) {
        PageHelper.startPage(pageNum,pageSize);
        List<Video> list = dao.seekVideo(videoName);
        PageInfo<Video> pageIndo = new PageInfo<>(list);
        return pageIndo;
    }
}
